package reduce.fz.com.reduce.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.bean.User;
import reduce.fz.com.reduce.bean.result.UserWitness;

/**
 * Created by qingshengzheng on 15/8/29.
 */
public class TeamDetailDynamicAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater layoutInflater;

    private List<UserWitness> userWitness;

    public TeamDetailDynamicAdapter() {
    }

    public TeamDetailDynamicAdapter(Context context,List<UserWitness> userWitness )
    {
        this.context=context;
        this.layoutInflater=LayoutInflater.from(context);
        this.userWitness=userWitness;
    }

    @Override
    public int getCount() {
        return userWitness.size();

    }

    @Override
    public Object getItem(int i) {
        return userWitness.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    static class ViewHolder{
        public ImageView userHeader;
        public TextView userName;
        public TextView wintessDesc;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder=null;
        if(view==null)
        {
            viewHolder=new ViewHolder();
            view= layoutInflater.inflate(R.layout.user_witness_state,null);
            viewHolder.userHeader = (ImageView) view.findViewById(R.id.user_header);
            viewHolder.userName=(TextView) view.findViewById(R.id.tv_user_name);
            view.setTag(viewHolder);
        }
        else
        {
            viewHolder= (ViewHolder) view.getTag();
        }
        //头像
        Picasso.with(context).load(R.drawable.shuaige).into(viewHolder.userHeader);
        viewHolder.userName.setText(userWitness.get(i).user.nickname);
        viewHolder.wintessDesc.setText(userWitness.get(i).pubTime.toString());
        return view;

    }
}
